PROJECT( TINKERCELL )

ADD_DEFINITIONS( 
  -DQT_NO_DEBUG -DQT_XML_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT
  -DINLINE=static -DYY_NEVER_INTERACTIVE -DPARSER_LP -DINVERSE_ACTIVE=INVERSE_LUSOL -DRoleIsExternalInvEngine )

SET( TINKERCELL_MAJOR_VERSION "1" )
SET( TINKERCELL_MINOR_VERSION "0" )

SET( TINKERCELL_VERSION
"${TINKERCELL_MAJOR_VERSION}.${TINKERCELL_MINOR_VERSION}.${TINKERCELL_WC_REVISION}" )

#--------------------------------------------------------------------------
# cmake policies
#--------------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED( VERSION 2.6 )

IF( COMMAND CMAKE_POLICY )
  CMAKE_POLICY( VERSION 2.4 )
  CMAKE_POLICY( SET CMP0005 NEW )
  CMAKE_POLICY( SET CMP0003 NEW )
ENDIF(COMMAND CMAKE_POLICY)

#---------------------------------------------------------------------------
# Define EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH
#---------------------------------------------------------------------------
SET(EXECUTABLE_OUTPUT_PATH
 ${TINKERCELL_BINARY_DIR}/bin
 CACHE PATH "Single output directory for building all executables."
)
SET(CPP_LIBRARY_OUTPUT_PATH
 ${TINKERCELL_BINARY_DIR}/bin/Plugins/
 CACHE PATH "Single output directory for building all cpp libraries."
)
SET(C_LIBRARY_OUTPUT_PATH
 ${TINKERCELL_BINARY_DIR}/bin/Plugins/c/
 CACHE PATH "Single output directory for building all c libraries."
)

#---------------------------------------------------------------------------
# Doxygen documentation
#---------------------------------------------------------------------------
OPTION( DOXYGENDOC "Generate Doxygen Documentation" OFF )

SET(CMAKE_BUILD_TYPE Debug)
#---------------------------------------------------------------------------
# Qt4
#---------------------------------------------------------------------------
FIND_PACKAGE( Qt4 )

#--------------------------------------------
# Build only if the version of qt is newer
# than Qt4.4. Note Qt starts being LGPL with
# Qt4.5
# IF( QT4_FOUND AND QT_VERSION_MINOR GREATER 4 )
IF( QT4_FOUND )
  IF( QT_USE_FILE )
	  SET( QT_USE_QTCORE TRUE )
	  SET( QT_USE_QTGUI TRUE )
	  SET( QT_USE_QTXML TRUE )
	  SET( QT_USE_QTOPENGL TRUE )
    SET( QT_USE_QT3SUPPORT FALSE )
    #SET( QT_USE_QTSVG TRUE )
    INCLUDE( ${QT_USE_FILE} )
  ELSE( QT_USE_FILE )
    SET( QT_LIBRARIES ${QT_QT_LIBRARY} )
  ENDIF( QT_USE_FILE )

  FIND_PACKAGE( GLUT )
  IF( GLUT_FOUND )
#	echo ("GLUT found\n")
  ELSE( GLUT_FOUND )
#	echo ("GLUT not found\n")
    SET( GLU_INCLUDE -I/usr/X11R6/include )
    SET( GLU_LIB -L/usr/X11R6/lib )
    SET( PTHREAD -lpthread )
  ENDIF( GLUT_FOUND )
  FIND_PACKAGE( X11 )
  SET( PTHREAD_DIR /usr/lib )
  FIND_PACKAGE(LibXml2)

  LINK_DIRECTORIES(
    ${CPP_LIBRARY_OUTPUT_PATH}
    ${C_LIBRARY_OUTPUT_PATH}

    ${GLU_LIB} 
    ${GLU_glut_LIBRARY}
    ${X11_LIBRARY_DIR}
    /usr/local/lib
    /usr/lib
    ${TINKERCELL_BINARY_DIR}
    ${TINKERCELL_BINARY_DIR}/bin
    ${TINKERCELL_BINARY_DIR}/ExternalCode
    ${TINKERCELL_BINARY_DIR}/ExternalCode/muparser
    ${TINKERCELL_BINARY_DIR}/Core/
    ${TINKERCELL_BINARY_DIR}/c/
    ${TINKERCELL_SOURCE_DIR}/ExternalCode/
    ${TINKERCELL_SOURCE_DIR}/ExternalCode/muparser/
    ${TINKERCELL_SOURCE_DIR}/Core/
    ${TINKERCELL_SOURCE_DIR}/c/
    ${TINKERCELL_SOURCE_DIR}/NodeGraphicsItem
    ${TINKERCELL_SOURCE_DIR}/

   )

  INCLUDE_DIRECTORIES( BEFORE
    ${PYTHON_INCLUDE_PATH}
    ${QT_INCLUDES}
    ${GLU_INCLUDE_DIR}
    ${GLU_INCLUDE}
    ${X11_INCLUDE_DIR}
    ${LIBXML2_INCLUDE_DIR}
# INCLUDE DIRECTORIES FROM TINKERCELL
  ${TINKERCELL_SOURCE_DIR}/ExternalCode/
    ${TINKERCELL_SOURCE_DIR}/ExternalCode/muparser/
    ${TINKERCELL_SOURCE_DIR}/Core/
    ${TINKERCELL_SOURCE_DIR}/c/
    ${TINKERCELL_SOURCE_DIR}/SimpleDesigner/
    ${TINKERCELL_SOURCE_DIR}/NodeGraphicsItem

 )
###target_link_libraries( pthread )
#----------------------------------------------------------------------------
#   Tinkercell plugins and other components
#----------------------------------------------------------------------------

  SET(TINKERCELL_BINARY_BIN_DIR TINKERCELL_BINARY_DIR/bin)
  
  ADD_SUBDIRECTORY( Core )
  ADD_SUBDIRECTORY( Main )
  ADD_SUBDIRECTORY( ExternalCode )  
  ADD_SUBDIRECTORY( SimpleDesigner )  
  ADD_SUBDIRECTORY( NodeGraphicsItem )  
  

#----------------------------------------------------------------------------
# Other programs (not really part of Tinkercell)
#----------------------------------------------------------------------------

  OPTION( BUILD_RELATED_PROGRAMS "SimpleDesigner, Multicell, SegmentationAnimation" OFF )

  IF( BUILD_RELATED_PROGRAMS )
     ADD_SUBDIRECTORY( SegmentationAnimation )
     ADD_SUBDIRECTORY( SimpleDesigner )
     ADD_SUBDIRECTORY( MultiCell )
     ADD_SUBDIRECTORY( NodeGraphicsItem )
     
  ENDIF( BUILD_RELATED_PROGRAMS )


#----------------------------------------------------------------------------
# Copyright and other files
#----------------------------------------------------------------------------

FILE(GLOB TINKERCELL_SUPPORTING_FILES about.txt COPYRIGHT.TXT )
INSTALL(FILES ${TINKERCELL_SUPPORTING_FILES} DESTINATION bin/../)  
  
ENDIF( QT4_FOUND )
